import Vue from 'vue'
import Router from 'vue-router'
import Home from './pages/home'
import Index from './pages/index'//主界面
import Product from './pages/product'//产品栈界面
import Detail from './pages/detail'//商品详情页面
import Cart from './pages/cart'//购物车页面
import Order from './pages/order'//订单请求
import OrderConfirm from './pages/orderConfirm'//订单确认
import OrderList from './pages/orderList'//订单列表
import OrderPay from './pages/orderPay'//订单支付
import AliPay from './pages/alipay'//支付宝页面
import Login from './pages/login'

Vue.use(Router);//加载插件的固定语法

//进行导出
export default new Router({
	routes:[//进行路由配置
		{
			//加载副路由
			path:'/',
			name:'home',//加载home组件，该组件中有嵌套视图，避免在每个页面重新导入<nav-header>
			component:Home,//根路由
			redirect:'/index',//重定向
			children:[//子路由
				{
					path:'/index',
					name:'index',
					component:Index,
				},{
					path:'/product/:id',//动态定义路由的语法
					name:'product',
					component:Product,
				},{
					path:'/detail/:id',
					name:'detail',
					component:Detail,
				}
			]
		},
		{
			//购物车用的不是home的结构了，所以不写在子路由里,又因为写在order里很怪，所以单独列出来
			path:'/cart',
			name:'cart',
			component:Cart,
		},
		{
			path:'/login',
			name:'login',
			component:Login,
		},
		{
			path:'/order',//一个副路由
			name:'order',
			component:Order,
			children:[//子路由
				{
					path:'list',
					name:'order-list',
					component:OrderList,

				},
				{
					path:'confirm',
					name:'order-confirm',
					component:OrderConfirm,
				},
				{
					path:'pay',
					name:'order-pay',
					component:OrderPay,
				},
				{
					path:'alipay',
					name:'alipay',
					component:AliPay,
				}
			]
		}
	]
});